public class DAY0109 {
    public static void main(String[] args) {
        Solution solution=new Solution();
        int a=solution.addDigits(38);
        System.out.println(a);
    }

}
class  Solution {
    public int addDigits(int num) {
        while (num >= 10) {
            int sum = 0;
            while (num > 0) {
                sum += num % 10;
                num /= 10;
            }
            num = sum;
        }
        return num;
    }
}